package timetest;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;

/**
 * @author shentianyu
 * @date 2021-06-25 23:09
 */
public class TestSimpleDateFormat {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyMMdd");
//
//        Callable<Date> callable = new Callable<Date>() {
//            @Override
//            public Date call() throws Exception {
//                return DateFormatThreadLocal.convert("20160627");
//            }
//        };
//
//        ExecutorService executorService = Executors.newFixedThreadPool(10);
//
//        List<Future<Date>> results = new ArrayList<>();
//
//        for (int i = 0; i < 10 ; i++) {
//            results.add(executorService.submit(callable));
//        }
//
//        for (Future<Date> future: results) {
//            System.out.println(future.get());
//        }
//
//        executorService.shutdown();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");

        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");



        Callable<LocalDate> callable = ()->LocalDate.parse("20210627",dtf);

        ExecutorService executorService = Executors.newFixedThreadPool(10);

        List<Future<LocalDate>> results = new ArrayList<>();

        for (int i = 0; i < 10 ; i++) {
            results.add(executorService.submit(callable));
        }

        for (Future<LocalDate> future: results) {
            System.out.println(future.get());
        }

        executorService.shutdown();


    }
}
